<?php

if(!isset($loggedIn))
{
    $loggedIn = '';
}

if(!isset($openID))
{
    $openID = '';
}

if(isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false)
{
	header('Content-type: application/xhtml+xml; charset=utf-8');
	echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
}
else
{
	header('Content-type: text/html; charset=utf-8');
}

echo $html->docType();

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
	<?php
		uses('sanitize');
		$sanitize = new Sanitize();
		echo $sanitize->html(QDB_NAME, true) . ' :: ' . $title_for_layout;
	?>
</title>
<link rel="search" type="application/opensearchdescription+xml" title="<?php echo $sanitize->html(QDB_NAME, true); ?>" href="<?php echo $this->webroot . 'files/opensearch.xml';?>" />
<?php

    echo $html->meta('icon', '/favicon.ico');
    echo $html->meta('rss', '/quotes/rss', array('title' => $sanitize->html(QDB_NAME, true) . ' RSS Feed'));
    echo $html->css('core');
    echo $html->css('default');

?>
<script type="text/javascript">
var CORE_URL = '<?php echo FULL_BASE_URL . '/'; ?>';
</script>
<script type="text/javascript" src="<?php echo $this->webroot . 'js/prototype.js' ?>"></script>
<script type="text/javascript" src="<?php echo $this->webroot . 'js/scriptaculous.js?load=effects' ?>"></script>
<script type="text/javascript" src="<?php echo $this->webroot . 'js/core.js' ?>"></script>
</head>
<body>
	<div id="container">
		<div id="header">
			<?php echo $this->renderElement('header', array('sanitize' => $sanitize)); ?>
		</div>
		<div id="middle">
		<div id="sidebar">
			<?php echo $this->renderElement('sidebar', array('loggedIn' => $loggedIn, 'openID' => $openID)); ?>
		</div>
		<div id="content">
			<?php
				if ($session->check('Message.flash'))
				{
					echo '<br />';
					$session->flash();
				}
				
				echo $content_for_layout;
			?>
		</div>
		</div>
		<div id="footer">
			<?php echo $this->renderElement('footer'); ?>
		</div>
	</div>
</body>
</html>
